<?php
session_start();

if (!isset($_SESSION['AdminId']) || $_SESSION['AdminId'] == "") {
    echo "<script type='text/javascript'>location.href='../admin.php'</script>";
}

require_once 'common/config.php';
require_once 'common/conn.php';
require_once 'common/function.php';

require_once 'db/account.db.php';
require_once 'db/accountMoney.db.php';

$id = isset($_GET['id']) ? $_GET['id'] : "";

$dbc = new DBC();

$balance = 0;
if ($id == "") {
    $accountId = "";
    $itemNo = "";
    $price = "";
    $imageUrl = "";
} else {
    $accountDb = new AccountDb($dbc);

    $data = $accountDb->getAccountById($id);

    if (isArrayNotEmpty($data)) {
        $accountId = $data[0]['AccountID'];
    }
    $accountMoneyDb = new AccountMoneyDb($dbc);

    $accountMoneyData = $accountMoneyDb->getAccountMoney($id);
    if (isArrayNotEmpty($accountMoneyData)) {
        $balance = $accountMoneyData[0]['Balance'];
    }
}

$dbc->close();
?>
<!DOCTYPE html>
<html>
    <head>
        <title>赠送金币</title>
        <meta charset="UTF-8">
        <link href="<?php echo $flatUi; ?>dist/css/vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">
    </head>
    <body>

        <div class="container">
            <div style="text-align: center">
                <h1>
                    赠送金币
                </h1>
            </div>
            <form class="form-horizontal" role="form" action="action/account.action.php" method="POST" enctype="multipart/form-data">
                <div class="form-group">
                    <label class="col-sm-2 control-label">用户</label>
                    <div class="col-sm-10">
                        <input name="action" type="hidden" value="sendGold">
                        <input id="accUnique" name="accUnique" type="hidden" value="<?php echo $id; ?>">
                        <input class="form-control" id="itemNo" name="itemNo" type="text" value="<?php echo $accountId; ?>" disabled="disabled">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">余额</label>
                    <div class="col-sm-10">
                        <input class="form-control" id="itemName" name="itemName" type="text" value="<?php echo $balance; ?>" disabled="disabled">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">赠送金币</label>
                    <div class="col-sm-10">
                        <input class="form-control" id="gold" name="gold" type="text" value="0" required>
                    </div>
                </div>
                <div style="width:100%; text-align: center">
                    <input type="submit" class="btn btn-primary" value="赠送"/>
                </div>
            </form>
        </div>
    </body>
</html>